/**
 * Created by user on 17/2/15.
 */

let uls = require('@futu/node-uls');
let cmlb = require('@futu/node-cmlb');

/**
 *
 * 通过 cmlb id 获取 endpoint
 *
 * @param {int} appId cmlbId
 * @param {string} defaultIp 默认 ip
 * @param {int} defaultPort 默认 port
 * @param {bool} isDev 是否是测试环境
 * @returns {Promise.<*>} endpoint
 */
exports.getEndpoint = async (appId, defaultIp, defaultPort, isDev = 0) => {
    try {
        return cmlb.getAddress(appId, isDev);
    } catch (error) {
        return { ip: defaultIp, port: defaultPort };
    }
};

exports.getLogger = function ( cmd = 0, subCmd = 0, uid = 0, ip = '0.0.0.0') {
    return uls.getLogger(cmd, subCmd, uid, ip);
};
